import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)


const store = new Vuex.Store({
	state: {
		positionName: "北京市",
		positionRegion: "",
		positionAdcode: "350121", //城市编码
		longitude: 119.216655, //经度
		latitude: 26.040612, //纬度
		questionOrderForm: {
			content: '', //病情描述
			doctorId: null, //医生id
			drugQuestionReq: { //开药问诊额外参数
				allergy: 0, //过敏 0:无 1:有
				allergyText: '', //过敏史描述
				birthStatus: 0, //生育计划 0:无 1:准备要孩子 2:怀孕中 3:正在哺乳
				kidney: 0, //肾功能 0:正常 1:异常
				liver: 0, //肝功能 0:正常 1:异常
				commodityList: []
			},
			duration: 0, //患病时长0:一周内 1:一月内 2:半年内 3:半年以上
			izLookHosp: 0, //是否去医院就诊过0:否1:有
			orderId: null, //订单id
			patientId: null, //患者id
			reportList: [], //报告列表
			type: 0, //订单类型 0:专家 1:极速 2:开药
			inquiryType: 0, //问诊类型  0图文  1视频
			subTime: "", //预约时间
			price: 0 //订单金额
		},

		recipeForm: {
			diagnose: "", //诊断
			//{commodityId: "", //商品id   commodityNum: 0 //商品数量}
			recipeDetailDTO: [], //药品信息 
			drugUseVo: {
				commodityNum: "", //用药数量
				frequency: '', //用药频率
				onceDosage: '', //单次用量
				remark: "", //备注
				useMethod: "", //用药方法
			},
			recipeType: 0 //0西药 1中药
		},
		
		userBankCard:null, //用户选择的银行卡
		userAddress: null, //用户选择的地址
		recipeInfo: null //聊天界面开处方的数据
	},
	mutations: {
		setPositionName(state, positionName) {
			state.positionName = positionName;
		},
		setPositionRegion(state, positionRegion) {
			state.positionRegion = positionRegion;
		},
		setPositionAdcode(state, positionAdcode) {
			state.positionAdcode = positionAdcode;
		},
		setLongitude(state, longitude) {
			state.longitude = longitude
		},
		setLatitude(state, latitude) {
			state.latitude = latitude
		},
		setQuestionOrderForm(state, questionOrderForm) {
			state.questionOrderForm = questionOrderForm
		},
		setRecipeForm(state, recipeForm) {
			state.recipeForm = recipeForm
		},
		setRecipeDetailDTO(state, recipeDetailDTO) {
			state.recipeForm.recipeDetailDTO = recipeDetailDTO
		},
		setRecipeInfo(state, recipeInfo) {
			state.recipeInfo = recipeInfo
		},
		setUserBankCard(state, userBankCard) {
			state.userBankCard = userBankCard
		},
		setUserAddress(state, userAddress) {
			state.userAddress = userAddress
		},
		clearQuestionOrderForm(state) {
			state.questionOrderForm = {
				content: '', //病情描述
				doctorId: null, //医生id
				drugQuestionReq: { //开药问诊额外参数
					allergy: 0, //过敏 0:无 1:有
					allergyText: '', //过敏史描述
					birthStatus: 0, //生育计划 0:无 1:准备要孩子 2:怀孕中 3:正在哺乳
					kidney: 0, //肾功能 0:正常 1:异常
					liver: 0, //肝功能 0:正常 1:异常
					commodityList: []
				},
				duration: 0, //患病时长0:一周内 1:一月内 2:半年内 3:半年以上
				izLookHosp: 0, //是否去医院就诊过0:否1:有
				orderId: null, //订单id
				patientId: null, //患者id
				reportList: [], //报告列表
				type: 0, //订单类型 0:专家 1:极速 2:开药
				inquiryType: 0, //问诊类型  0图文  1视频
				subTime: "", //预约时间
				price: 0 //订单金额
			}
		},
		clearRecipeForm(state) {
			state.recipeForm = {
				diagnose: "", //诊断
				//{commodityId: "", //商品id   commodityNum: 0 //商品数量}
				recipeDetailDTO: [], //药品信息 
				drugUseVo: {
					commodityNum: "", //用法用量
					frequency: '', //用药频率
					onceDosage: '', //单次用量
					remark: "", //备注
					useMethod: "", //用药方法
				},
				recipeType: 0 //0西药 1中药
			}
		}
				
	},
	getters: {
		getPositionName(state) {
			return state.positionName
		},
		getPositionRegion(state) {
			return state.positionRegion
		},
		getPositionAdcode(state) {
			return state.getPositionAdcode
		},
		getLongitude(state) {
			return state.longitude
		},
		getLatitude(state) {
			return state.latitude
		},
		getQuestionOrderForm(state) {
			return state.questionOrderForm
		},
		getRecipeForm(state) {
			return state.recipeForm
		},
		getRecipeInfo(state) {
			return state.recipeInfo
		},
		getUserBankCard(state) {
			return state.userBankCard
		},
		getUserAddress(state) {
			return state.userAddress
		}
		


	},
	actions: {

	},
})

export default store
